package cn.edu.stu.syllabus.repository.oa;

import java.util.ArrayList;
import java.util.List;

import cn.edu.stu.syllabus.repository.oa.local.OaInfoEntry;
import cn.edu.stu.syllabus.repository.oa.remote.OaInfo;
import cn.edu.stu.syllabus.utils.ListUtils;

/**
 * Created by daidaijie on 2017/3/14.
 */

public class OaInfoConverter {

    public static List<OaInfoEntry> convert(List<OaInfo> oaInfos) {
        List<OaInfoEntry> oaInfoEntries = new ArrayList<>();
        if (ListUtils.getListSizeSafety(oaInfos) != 0) {
            for (OaInfo oaInfo : oaInfos) {
                oaInfoEntries.add(convert(oaInfo));
            }
        }
        return oaInfoEntries;
    }

    public static OaInfoEntry convert(OaInfo oaInfo) {
        OaInfoEntry oaInfoEntry = new OaInfoEntry();

        oaInfoEntry.setMRemoteId(oaInfo.getID());
        oaInfoEntry.setMTitle(oaInfo.getDOCSUBJECT());
        oaInfoEntry.setMSubCompanyName(oaInfo.getSUBCOMPANYNAME());
        oaInfoEntry.setMSubCompanyId(oaInfo.getSUBCOMPANY_ID());
        oaInfoEntry.setMDocContent(oaInfo.getDOCCONTENT());
        oaInfoEntry.setMSubCompanyName(oaInfo.getSUBCOMPANYNAME());
        oaInfoEntry.setMDate(oaInfo.getDOCVALIDDATE());
        oaInfoEntry.setMTime(oaInfo.getDOCVALIDTIME());
        oaInfoEntry.setMAccessFileCount(oaInfo.getACCESSORYCOUNT());

        return oaInfoEntry;
    }
}
